// src/access.ts
type CurrentUser = {
  id?: number;
  username?: string;
  permissions?: string[];
  avatar?: string,
};

export default function access(initialState: { currentUser?: CurrentUser } ={}) {
  const { currentUser={} } = initialState;
  return {
    canAccess: !!currentUser, // 登录状态
    // 动态路由news的权限判断
    canNewsView: (id:string)=>{
      return currentUser?.permissions?.includes(`canNewsView_${id}`)
    }
  };
}